package com.e2oto.seller.common.base;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.WindowManager;

import com.e2oto.seller.R;

import butterknife.ButterKnife;

/**
 * Created by ZhangLiQiang on 2017/11/11.
 */

public abstract class BaseTranslucentDialog extends Dialog {

    private Context mContext;

    public BaseTranslucentDialog(@NonNull Context context) {
        super(context, R.style.translucent_no_title);
        this.mContext = context;
    }

    @Override
    public void show() {
        super.show();
        /**
         * 设置宽度全屏，要设置在show的后面
         */
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity = Gravity.CENTER;
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().getDecorView().setPadding(DensityTools.dp2px(mContext, 10), 0, DensityTools.dp2px(mContext, 10), 0);
        getWindow().setAttributes(layoutParams);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentView());
        ButterKnife.bind(this);
        afterView();
    }

    public abstract int getContentView();

    public abstract void afterView();
}
